export type QuestionItemType = {
  title: string | number;
  value: any;
  id?: string | number;
  key?: string;
  disabled?: boolean;
  isInput?: boolean;
  isDefault?: boolean;
  isExclusion?: boolean;
  isDesignAdd?: boolean;
  isIndividual?: boolean;
  isHovered?: boolean;
  designMode?: DesignModeType;
};

export type MapQuestionItemType = {
  longitude?: string | number;
  latitude?: string | number;
  searchKey?: string;
};

export type ShortAnswerItemType = {
  isWordLimit: boolean;
  minCharCount?: number;
  maxCharCount?: number;
};

export type QuestionTypeString =
  | 'single'
  | 'multiple'
  | 'answer'
  | 'map'
  | 'scale'
  | 'paragraph'
  | 'paging'
  | 'startPage'
  | 'endPage';
export type DesignModeType = 'original' | 'add' | 'delete';
export type LanguageTypeString = 'zh' | 'en';
export type ModeTypeString = 'design' | 'preview' | 'product';
export type LanguageTypeArray = ['zh' | 'en'];
export type QuestionProperType = {
  title: string;
  items?: Array<QuestionItemType>;
  mapItem?: MapQuestionItemType;
  hasIndividual?: boolean;
  shortAnswerItem?: ShortAnswerItemType;
};

export type DisplayRuleType = {
  hideQuestion: boolean;
  timeLimit: boolean;
  timeDataField?: string;
  timeFrame?: Array<any>;
  storeLimit: boolean;
  cityLimit: boolean;
  storeFile?: any;
  cityFile?: any;
  recyclingLimit: boolean;
  upperLimitNum?: number;
  channelLimit: boolean;
  channelList?: any[];
};

export type JumpValueType = {
  optionId: string | number;
  optionTitle: string;
  optionValue: any;
  jumpToQuestionNumber: number;
};

export type JumpRuleType = {
  optionJump: boolean;
  optionJumpValues?: Array<JumpValueType>;
  unconditionJump: boolean;
  unconditionJumpValue?: number;
};

export type QuestionType = {
  id: string | number;
  number?: string | number;
  key?: string;
  mode: ModeTypeString;
  type: QuestionTypeString;
  order: number;
  pageNumber?: number;
  index?: number;
  name?: string;
  value?: any;
  mustAnswer?: boolean;
  activeDesignLanguage?: LanguageTypeString;
  designMode?: DesignModeType;
  questionProperZh?: QuestionProperType;
  questionProperEn?: QuestionProperType;
  displayRule?: DisplayRuleType;
  jumpRule?: JumpRuleType;
  associationRule?: any;
};

export type QuestionnaireType = {
  name: string;
  language: LanguageTypeArray;
  startDate: string;
  endDate: string;
  footer: string;
  questions?: Array<QuestionType>;
  pageTotal?: number;
  mode: ModeTypeString;
  activeQuestionIndex?: number;
  status: 'new' | 'publish' | 'publish-edit' | 'pause';
};
